package com.ruoyi.common.sms;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;

import java.io.IOException;
import java.io.UnsupportedEncodingException;

public class Demo_Client {

    @Value("${sms.pwd}")
    private static String sn;

    @Value("${sms.pwd}")
    private static String pwd;

    public static void main(String[] args) throws UnsupportedEncodingException {
        sendSMS("17671058424", "test");
    }

    /**
     * 发送手机验证码
     *
     * @param mobie
     * @param msg
     * @return
     */
    public static boolean sendSMS(String mobie, String msg) {
        try {
            Client client = new Client(sn, pwd);

            //短信发送
            String content = java.net.URLEncoder.encode(msg + "[淘财宝365]", "utf-8");
            String result_mt = client.mdsmssend(mobie, content, "", "", "", "");

            return true;
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
            return false;
        } catch (IOException e) {
            e.printStackTrace();
            return false;
        }

    }
}
